package com.shop.controller;

import com.shop.pojo.Phone;
import com.shop.pojo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.Date;

/**
 * 本来用来演示:
 *
 * @author success
 * @date 2024/6/19 08:07:18
 */
@Controller
@RequestMapping("cc")
public class ControllerAnno {

    //localhost:8088/boot/cc/hello
    //把控制层方法的返回结果当成是一个页面.
    @GetMapping("hello")
    public String hello(){
        //需要在resources/static/下面新建一个hello.html
        return "/hello.html";
    }

    @ResponseBody
    @GetMapping("index")
    public String index(){
        //需要在resources/static/下面新建一个hello.html
        return "/hello.html";
    }


    @ResponseBody
    @GetMapping("xx")
    public Result xx(){
        Phone phone = new Phone();
        phone.setId(1);
        phone.setName("小米");
        phone.setCreateDate(new Date());
        phone.setImgUrl("xx.png");
        phone.setStock(100);
        return new Result("200","查询成功",phone);
    }
}
